package com.chixing.controller;


import com.chixing.entity.Car;
import com.chixing.entity.Flow;
import com.chixing.entity.LoginCustomer;
import com.chixing.entity.Orders;
import com.chixing.service.ICarService;
import com.chixing.service.IFlowService;
import com.chixing.service.IOrdersService;
import com.chixing.util.Result;
import com.chixing.util.TokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author shy
 * @since 2022-11-02
 */
@Controller
@RequestMapping("/flow")
public class FlowController {
    @Autowired
    private IFlowService flowService;
    @Autowired
    private IOrdersService ordersService;
    @Autowired
    private ICarService carService;
    @GetMapping("/getFlow/{id}")
    public ModelAndView getById(@PathVariable("id") Integer orderId, HttpServletRequest request){
        Result result = ordersService.getById(orderId);
        Flow rows = flowService.getById(orderId);
        Orders orders = (Orders)result.getData();
        Integer carId = orders.getCarId();
        Car car = carService.getById(carId);
//        System.out.println("Car的属性："+car);
        ModelAndView mav = new ModelAndView();

        mav.addObject("flowData",rows);
        mav.addObject("OrderData",result);
        mav.addObject("carData",car);
        mav.setViewName("customer/personalCenter-OrlerpaySuccess");
        return mav;
    }
}
